﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.TransportMgtServiceRef;

    public class TransportMgtServiceClientProxy : BasePage
    {
        public string ConfirmPOD(PodInfo podInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.ConFirmPOD(podInfo, pubParasInfo);
            }
        }

        public string DeleteBolDetailInfo(List<string> bolDetailInfoIDs, List<string> lineIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.DeleteBolDetailInfo(bolDetailInfoIDs, lineIDs, pubParasInfo);
            }
        }

        public string DeleteDeliveryOrder(List<string> deliveryOrderIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.DeleteDeliveryOrder(deliveryOrderIDs, pubParasInfo);
            }
        }

        public string DeleteDispatchInfo(List<string> dispatchInfoDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.DeleteDispatchInfo(dispatchInfoDs, pubParasInfo);
            }
        }

        public string DeletePodInfo(List<string> podIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.DeletePodInfo(podIDs, pubParasInfo);
            }
        }

        public string DeleteTrackingDetail(List<string> trackingDetailIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.DeleteTrackingDetail(trackingDetailIDs, pubParasInfo);
            }
        }

        public DataSet GetAllBolDetailInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetAllBolDetailInfo(pubParasInfo);
            }
        }

        public DataSet GetAllDeliveryOrderInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetAllDeliveryOrderInfo(pubParasInfo);
            }
        }

        public DataSet GetAllDispatchInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetAllDispatchInfo(pubParasInfo);
            }
        }

        public DataSet GetAllpodInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetAllPodInfo(pubParasInfo);
            }
        }

        public DataSet GetAllTrackingDetailInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetAllTrackingDetailInfo(pubParasInfo);
            }
        }

        public DataSet GetBolDetailByQueryEntity(BolDetailQueryEntity bolDetailQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetBolDetailInfoByQueryEntity(bolDetailQuery, pubParasInfo);
            }
        }

        public List<BolDetailInfo> GetBolDetailInfoByDeliveryOrderIDsAndEquipmentTypeID(List<string> DeliveryOrderIDs, string EquipmentTypeIDs, string types)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetBolDetailInfoByDeliveryOrderIDsAndEquipmentTypeID(DeliveryOrderIDs, EquipmentTypeIDs, types, pubParasInfo);
            }
        }

        public BolDetailInfo GetBolDetailInfoByID(string bolDetailInfo, string lineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetBolDetailInfoByID(bolDetailInfo, lineID, pubParasInfo);
            }
        }

        public DataSet GetDeliveryOrderByQueryEntity(DeliveryOrderQueryEntity deliveryOrderQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetDeliveryOrderInfoByQueryEntity(deliveryOrderQuery, pubParasInfo);
            }
        }

        public DeliveryOrderInfo GetDeliveryOrderInfoByID(string deliveryOrderID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetDeliveryOrderInfoByID(deliveryOrderID, pubParasInfo);
            }
        }

        public DispatchInfo GetDispatchInfoByID(string dispatchID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetDispatchInfoByID(dispatchID, pubParasInfo);
            }
        }

        public DataSet GetDispatchInfoByQueryEntity(DispatchQueryEntity dispatchQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetDispatchInfoByQueryEntity(dispatchQuery, pubParasInfo);
            }
        }

        public static TransportMgtServiceClientProxy GetInstance()
        {
            return new TransportMgtServiceClientProxy();
        }

        public PodInfo GetPodInfoByID(string podID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetPodInfoByID(podID, pubParasInfo);
            }
        }

        public DataSet GetPodInfoByQueryEntity(PodQueryEntity podQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetPodInfoByQueryEntity(podQuery, pubParasInfo);
            }
        }

        public TrackingDetailInfo GetTrackingDetailInfoByID(string trackingDetailID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetTrackingDetailInfoByID(trackingDetailID, pubParasInfo);
            }
        }

        public DataSet GetTrackingDetailInfoByQueryEntity(TrackingDetailQueryEntity trackingDetailQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.GetTrackingDetailInfoByQueryEntity(trackingDetailQuery, pubParasInfo);
            }
        }

        public string ImportFormShippingOrder(string orderID, string vDeliveryOrderID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.ImportFormShippingOrder(orderID, vDeliveryOrderID, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertBolDetailInfo(BolDetailInfo bolDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertBolDetailInfo(bolDetailInfo, pubParasInfo);
            }
        }

        public string InsertBolDetailList(List<BolDetailInfo> bolDetailInfos)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertBolDetailList(bolDetailInfos, pubParasInfo);
            }
        }

        public string InsertDeliveryOrderInfo(DeliveryOrderInfo deliveryOrderInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertDeliveryOrder(deliveryOrderInfo, pubParasInfo);
            }
        }

        public string InsertDispatchAndBolDetailList(DispatchInfo dispatchInfo, List<BolDetailInfo> bolDetailInfos)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertDispatchAndBolDetailList(dispatchInfo, bolDetailInfos, pubParasInfo);
            }
        }

        public string InsertDispatchInfo(DispatchInfo dispatchInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertDispatchInfo(dispatchInfo, pubParasInfo);
            }
        }

        public string InsertPodInfo(PodInfo podInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertPodInfo(podInfo, pubParasInfo);
            }
        }

        public string InsertTrackingDetail(TrackingDetailInfo trackingDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.InsertTrackingDetail(trackingDetailInfo, pubParasInfo);
            }
        }

        public string UpdateBolDetailInfo(BolDetailInfo bolDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.UpdateBolDetailInfo(bolDetailInfo, pubParasInfo);
            }
        }

        public string UpdateBolDetailList(List<BolDetailInfo> bolDetailInfos)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.UpdateBolDetailList(bolDetailInfos, pubParasInfo);
            }
        }

        public string UpdateDeliveryOrder(DeliveryOrderInfo deliveryOrderInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.UpdateDeliveryOrder(deliveryOrderInfo, pubParasInfo);
            }
        }

        public string UpdateDispatchInfo(DispatchInfo dispatchInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.UpdateDispatchInfo(dispatchInfo, pubParasInfo);
            }
        }

        public string UpdatePodInfo(PodInfo podInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.UpdatePodInfo(podInfo, pubParasInfo);
            }
        }

        public string UpdateTrackingDetail(TrackingDetailInfo trackingDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtServiceClient client = new TransportMgtServiceClient("WSHttpBinding_ITransportMgtService"))
            {
                return client.UpdateTrackingDetail(trackingDetailInfo, pubParasInfo);
            }
        }
    }
}

